<?php
/*
 *   This file is part of verbum.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 	 Copyright (c) 2008 Sergio Gabriel Teves <gabriel.sgt at gmail.com>
 */

if ($op=="save") {

	$lang = $CURRENT_USER->lang;
	
	$CURRENT_USER->name=$param['name'];
	$CURRENT_USER->mail=$param['email'];
	$CURRENT_USER->lang=$param['langid'];
	$CURRENT_USER->timezone=$param['timezone'];
	
	$oldpass=$CURRENT_USER->userid;
	if ($param['password']!="") {
		$oldpass = $CURRENT_USER->currentpwd;
		$CURRENT_USER->password=$param['password'];
	}
	
	$ret = $loader->update($CURRENT_USER);

	// UPDATE REMEMBER ME INFO	
	$lginfo = getLoginCredentials();
	if ($lginfo->userid==$CURRENT_USER->userid && $lginfo->pass==$oldpass) {
		setLoginCredentials($us);
	}
			
	updateLang($CURRENT_USER->lang);
	cache('s_user',$CURRENT_USER);
	
	if ($CURRENT_USER->lang!=$lang) {
		success('reload');	
	} else {
		success();
	}

} else {
	include(ROOT_PATH."/form/user_preferences_form.php");
}
?>